<template>
  <div>
    <el-table
      :data="sec"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      :tree-props="{ children: 'children' }"
    >
      <el-table-column prop="title" label="活动名称" sortable width="180">
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template v-slot="scope">
          <el-button v-if="scope.row.status === 1" type="success"
            >启用</el-button
          >
          <el-button v-else type="danger"> 禁用 </el-button>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="edit(scope.row.id)">编辑</el-button>
          <el-button type="danger" @click="del(scope.row.id)"> 删除 </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapActions, mapGetters } from "vuex";
import { successAlert } from "../../../utils/alert";
import {secDel} from "../../../request/api"
export default {
  computed: {
    ...mapGetters({
      sec: "seckill/sec",
    }),
  },
  methods: {
    ...mapActions({
      secListActions: "seckill/secListActions",
    }),
    del(id) {
      // this.cateDelActions({ id });
      // this.secListActions();
      secDel({id});
      successAlert("删除成功")
       this.secListActions();
    },
    edit(id) {
      this.$emit("edit", id); 
    },
  },
  mounted() {
    this.secListActions();
  },
};
</script>

<style>
</style>